package demo4;

public class TestDefineException {
    public String userName="dzj";
    public String passWord="1234";
    public void logIn(String userName,String passWord) throws UserNameException ,PassWordException{
        if(!this.userName.equals(userName)){
            throw new UserNameException("用户名错误");
        }else if(!this.passWord.equals(passWord)){
            throw new PassWordException("密码错误");
        }
        System.out.println("登录成功");
    }

    public static void main(String[] args) {
        TestDefineException testDefineException=new TestDefineException();
        try{
            testDefineException.logIn("dzj","123");
        }catch (PassWordException|UserNameException e){
            e.printStackTrace();
        }finally {
            System.out.println("finally");
        }


    }
}
